import java.io.*;
import java.util.Scanner;

public class IPCategory {

    public static void main(String[] args) throws FileNotFoundException {
        solve(new FileInputStream("ip.txt"));
    }

    public static boolean checkCover(String cover) {
        String regrex = "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})";
        if (!cover.matches(regrex)) {
            return false;
        }
        final String[] nums = cover.split("\\.");

        // 只能是256-1，256-3，256-7。。。
        // 掩码取反？
        boolean is255 = true;
        for (String num: nums) {
            int i = Integer.parseInt(num);
            if (!is255 && i != 0) {
                // 检测是不是0
                return false;
            } else {
                is255 = is255 && i == 255;
                if (is255) {
                    continue;
                }
                int k = 1;
                while (i != 256 - k) {
                    k = k*2;
                    if (k > 256) {
                        return false;
                    }
                }
            }
        }
        return !is255;
    }

    public static void solve(InputStream in) {
        Scanner scanner = new Scanner(in);
        int A = 0;
        int B = 0;
        int C = 0;
        int D = 0;
        int E = 0;
        int P = 0;
        int ERR = 0;
        while (scanner.hasNext()) {
            String line = scanner.nextLine();
            final String[] split = line.split("~");
            // 左边是ip,右边是掩码
            String regrex = "(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})\\.(\\d{1,3})";
            // 先算有没有错
            boolean error = !checkCover(split[1]);
            if (error) {
                ERR += 1;
            } else if (split[0].matches(regrex)) {
                // 计算abcde类
                final String[] sp = split[0].split("\\.");
                // 先看是不是都符合
                for (String s : sp) {
                    final int i = Integer.parseInt(s);
                    if (i > 255) {
                        // 错误的码
                        error = true;
                        ERR ++;
                        break;
                    }
                }
                if (!error) {
                    int first = Integer.parseInt(sp[0]);
                    if (first > 0 && first < 127) {
                        System.out.println(line);
                        A ++;
                    }
                    if (first >= 128 && first < 192) {

                        B ++;
                    }
                    if (first >= 192 && first < 224) {

                        C ++;
                    }
                    if (first >= 224 && first < 240) {

                        D ++;
                    }
                    if (first >= 240 && first < 256) {

                        E ++;
                    }
                    if (first == 10) {
                        P ++;
                    }
                    if (first == 172
                            || first == 192) {
                        int second = Integer.parseInt(sp[1]);
                        if (first == 172 && second >= 16 && second < 32) {
                            P ++;
                        }
                        if (first == 192 && second == 168) {
                            P ++;
                        }
                    }
                }
            } else {

                ERR ++;
            }
        }
        System.out.println(A+" " + B + " " + C + " " + D + " " + E+" " + ERR + " " + P);
    }

}
